﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
using Xfm;
using Xfm.Core;
using Xfm.Core.Auth;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class XfmMvcExtention
    {
        public static IServiceCollection AddXfmFramework(this IServiceCollection services, XfmConfig xfmConfig)
        {
            //基础服务
            services.AddHttpContextAccessor();
            services.AddSingleton(xfmConfig);
            services.AddSingleton<IXfmService, XfmService>();
            //services.AddScoped<UserManager>();

            //core业务相关
            App.Services = services;
            //var dbContextDescriptor = services.FirstOrDefault(m => m.ServiceType.IsSubclassOf(typeof(BaseDbContext)));
            //App.DbContextType = dbContextDescriptor.ServiceType;
            return services;
        }
    }
}
